﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Onlyle.Business;
using Onlyle.Model;
using System.Data;
using Onlyle.Models;
using Industry.Framework.Common;
using System.Text.RegularExpressions;
using Industry.Framework.Common.Helper;

namespace Onlyle.Controllers
{
    public class GaoXiaoController : Controller
    {
        //
        // GET: /GaoXiao/kybmt52nyd0
        string publicPage = "~/Views/gaoxiao/_gaoxiaoPage.cshtml";
        GaoXiao_ArticleBLL articlebll = new GaoXiao_ArticleBLL();

        public ActionResult index()
        {
            AddHeadMeta("homeindex_title", "homeindex_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.gaoxiao.ToString());
        }
        public ActionResult neihan()
        {
            AddHeadMeta("neihan_title", "neihan_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.neihan.ToString());
        }

        public ActionResult meinvfuli()
        {
            AddHeadMeta("meinvfuli_title", "meinvfuli_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.meinvfuli.ToString());
        }
        public ActionResult tucao()
        {
            AddHeadMeta("tucao_title", "tucao_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.tucao.ToString());
        }
        public ActionResult fuqi()
        {
            AddHeadMeta("fuqi_title", "fuqi_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.fuqi.ToString());
        }
        public ActionResult lengxiaohua()
        {
            AddHeadMeta("lengxiaohua_title", "lengxiaohua_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.lengxiaohua.ToString());
        }
        public ActionResult qiusi()
        {
            AddHeadMeta("qiusi_title", "qiusi_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.qiushi.ToString());
        }
        public ActionResult diaosi()
        {
            AddHeadMeta("diaosi_title", "diaosi_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.diaosi.ToString());
        }
        public ActionResult egao()
        {
            AddHeadMeta("egao_title", "egao_keyword");
            return CreateGaoXiaoPage(GaoXiaoTypeEnum.egao.ToString());
        }
        public ActionResult detail(string id)
        {
            List<E_GaoXiao_Article> DetailList = articlebll.SelectGaoXiao_Detail(id);
            return View(DetailList);
        }
        ActionResult CreateGaoXiaoPage(string type)
        {
            string pageNum = (Request.QueryString["p"] ?? "").ToString();
            List<E_GaoXiao_Article> ArticleList = articlebll.Select(pageNum, type);
           
            GaoXiaoListModel gaoxiaoModel = new GaoXiaoListModel();
            gaoxiaoModel.ArticleList = ArticleList;
            ViewBag.PageCount = articlebll.GetGaoXiaoArticleCountByType(type);
            ViewBag.Type = type;
            return View(publicPage, gaoxiaoModel);
        }
        void AddHeadMeta(string title, string keywords)
        {
            string description = ConfigHelper.GetConfigString("gaoxiao_description");
            ViewData["title"] = ConfigHelper.GetConfigString(title);
            ViewData["keyword"] = ConfigHelper.GetConfigString(keywords);
            ViewData["description"] = description;
        }

    }
}
